POV-Ray : Newsgroups : povray.beta-test : Problems with functions in beta 16 : Problems with functions in beta 16 Server Time
29 Jul 2024 16:28:55 EDT (-0400)
  Problems with functions in beta 16  
From: Christoph Hormann
Date: 8 Apr 2002 11:13:31
Message: <3CB1B39A.3F70A85A@gmx.de>
While working on a new version of the IsoCSG library, i came across
several problems in beta 16.

(Beta 16 icl, WinNT4, K6)

1) The following code generates an error about recursive function calls
(in both versions for '#declare fn_A...'):

#declare IC_Arr=array[4]

#macro IC_Merge4(fn_A, fn_B, fn_C, fn_D)
  function {  
    min(fn_A(x, y, z),
        fn_B(x, y, z),
        fn_C(x, y, z),
        fn_D(x, y, z))      
  }
#end 

#declare IC_Arr[0]=function(x, y, z) { x }  
#declare IC_Arr[1]=function(x, y, z) { y }  
#declare IC_Arr[2]=function(x, y, z) { z }    
#declare IC_Arr[3]=function(x, y, z) { x+y }  

//#declare fn_A= IC_Merge4(function { IC_Arr[0](x, y, z) }, function {
IC_Arr[1](x, y, z) }, function { IC_Arr[2](x, y, z) }, function {
IC_Arr[3](x, y, z) }) 
#declare fn_A= IC_Merge4(IC_Arr[0], IC_Arr[1], IC_Arr[2], IC_Arr[3]) 






2) The following code crashes Povray during render (requires iso_csg 0.3)
I tried to simplify this, but came across the problem mentioned above and
therefore had difficulties making a simple example.

#version 3.5;

global_settings {
  assumed_gamma 1.0 
}   

background { color <0.750,0.500,0.300> } 
    
camera {
  location <0.2,0.2,-1>  
  look_at  <0,0,0>
  right (4/3)*x                
} 

light_source {     
  <1000, 2500, -5000> 
  color rgb 1.2
}     

#include "iso_csg.inc" 

#declare IC_Arr=array[12]

#macro IC_Merge_Array(Array)  
  #local Size=dimension_size(Array,1);

  function {
    min(
      #local Counter=0;
      #while (Counter<Size)
        #if (Counter>0) , #end
          Array[Counter] (x,y,z)
        #local Counter=Counter+1;
      #end
    )
  }
#end

#declare IC_Arr[0]=IC_Cone(0, 0, x+y, 1)                     
#declare IC_Arr[1]=IC_Rotate(IC_Arr[0], 30*z)                   
#declare IC_Arr[2]=IC_Rotate(IC_Arr[1], 60*z)
#declare IC_Arr[3]=IC_Rotate(IC_Arr[2], 90*z)
#declare IC_Arr[4]=IC_Rotate(IC_Arr[3], 120*z)
#declare IC_Arr[5]=IC_Rotate(IC_Arr[4], 150*z)     
#declare IC_Arr[6]=IC_Rotate(IC_Arr[5], 180*z)
#declare IC_Arr[7]=IC_Rotate(IC_Arr[6], 210*z)
#declare IC_Arr[8]=IC_Rotate(IC_Arr[7], 240*z)      
#declare IC_Arr[9]=IC_Rotate(IC_Arr[8], 270*z)    
#declare IC_Arr[10]=IC_Rotate(IC_Arr[9], 300*z)      
#declare IC_Arr[11]=IC_Rotate(IC_Arr[10], 330*z)   

#declare fn_XX= IC_Merge_Array(IC_Arr) 

isosurface
{                                                                                     
  function { fn_XX(x, y, z) }  
  max_gradient 1.6 
  contained_by { box { -2, 2 } }
  pigment { rgb <0, 0.2, 1.1> } 
  finish { specular 0.3 } 
  scale 0.1
}   

-- 
POV-Ray tutorials, IsoWood include,                 
TransSkin and more: http://www.tu-bs.de/~y0013390/  
Last updated 18 Mar. 2002 _____./\/^>_*_<^\/\.______


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.